from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
import time

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.baidu.com")

# 设置浏览器隐式等待时长：10s
driver.implicitly_wait(10)
# 定位搜索设置
# set_ele = driver.find_element(By.XPATH, "//span[text()='搜索设置']")
start_time = time.time()
try:

    # # 使用显示等待定位  (By.XPATH, "//span[text()='搜索设置']")
    # set_ele = WebDriverWait(driver, 10, 0.5).until(EC.presence_of_element_located((By.XPATH, "//span[text()='搜索设置']")))
    set_ele = driver.find_element(By.XPATH, "//span[text()='搜索设置']")
except:
    pass
end_time = time.time()

print("查找元素用时：", end_time-start_time)
driver.quit()